import Toybox.Lang;
import Toybox.WatchUi;

class NovelDelegate extends WatchUi.BehaviorDelegate {

    hidden var _view as NovelView;

    // Modify constructor to accept the view instance
    function initialize(view as NovelView) {
        BehaviorDelegate.initialize();
        _view = view; // Store the passed view instance
    }

    function onMenu() as Boolean {
        WatchUi.pushView(new Rez.Menus.MainMenu(), new NovelMenuDelegate(), WatchUi.SLIDE_UP);
        return true;
    }

    function onNextPage() as Boolean {
        _view.scrollDown(); // Changed from nextPage to scrollDown
        // WatchUi.requestUpdate(); // Removed: requestUpdate is now called within NovelView's page change methods
        return true;
    }

    function onPreviousPage() as Boolean {
        _view.scrollUp(); // Changed from previousPage to scrollUp
        // WatchUi.requestUpdate(); // Removed: requestUpdate is now called within NovelView's page change methods
        return true;
    }

    // Handle the Start/Stop button press (usually mapped to onSelect)
    function onSelect() as Boolean {
        _view.toggleAutoScroll();
        return true;
    }

}